import { createRouter, createWebHashHistory } from "vue-router"

const routes = [
  {
    path: '/',
    component:() => import('@/views/parent/Index.vue'),
  },
  {
    path: '/admin',
    redirect: '/admin/produ',
    component: () => import('@/views/parent/Admin.vue'),
    children: [
      {
        path: '/admin/produ',
        component: () => import('@/views/child/admin/AdminProdu.vue'),
      },
      {
        path: '/admin/data',
        component: () => import('@/views/child/admin/AdminData.vue'),
      },
      {
        path: '/admin/data/:id',
        component: () => import('@/views/child/admin/adminData/DataDetail.vue'),
      },
      {
        path: '/admin/temp',
        component: () => import('@/views/child/admin/AdminTemp.vue'),
      },
      {
        path: '/admin/collect',
        component: () => import('@/views/child/admin/AdminCollect.vue'),
      },
    ],
  },
  {
    path: '/publicity',
    name: 'publicity',
    component: () => import('@/views/parent/Publicity.vue'),
    props: true,
  },
  {
    path: '/h5edit/:id',
    name: 'h5edit',
    component: () => import('@/views/parent/H5Edit.vue'),
    props: true,
  },
  {
    path: '/cardedit/:id',
    name: 'cardedit',
    component: () => import('@/views/parent/CardEdit.vue'),
    props: true,
  },
  // {
  //   path: '/doc',
  //   name: 'doc',
  //   component: () => import('@/views/parent/doc.vue'),
  //   props: true,
  // },
]

const router = createRouter({
  history: createWebHashHistory(),
  scrollBehavior(to, from, savedPosition) {
    // always scroll to top
    return { top: 0 }
  },
  routes
})

export default router
